<template>
  <el-tabs type="border-card" class="ef-summary-w">
    <el-tab-pane
      label="表位故障模拟"
      class="ll-content"
      v-loading="faultLoading"
    >
      <div class="ll-btn1">
        <fieldset>
          <legend>表位故障:</legend>
          <div>
            <el-form class="ll-bw" ref="twfFormRef" :model="twfForm">
              <fieldset>
                <legend>485线路故障:</legend>
                <div>
                  <el-checkbox-group
                    class="ll-bw-item1"
                    v-model="twfForm.ttype"
                  >
                    <el-checkbox label="A_DISCONNECT">485A断</el-checkbox>
                    <el-checkbox label="B_DISCONNECT">485B断</el-checkbox>
                    <el-checkbox label="A_B_CROSS">485AB反接</el-checkbox>
                    <el-checkbox label="A_B_BY_PASS">485AB短路</el-checkbox>
                  </el-checkbox-group>
                </div>
              </fieldset>
              <fieldset>
                <legend>电压线路故障:</legend>
                <div class="ll-bw-item2">
                  <div>
                    <el-checkbox-group class="item" v-model="twfForm.vlf">
                      <el-checkbox label="U_A_DISCONNECT"
                        >A相电压断路</el-checkbox
                      >
                      <el-checkbox label="U_B_DISCONNECT"
                        >B相电压断路</el-checkbox
                      >
                      <el-checkbox label="U_C_DISCONNECT"
                        >C相电压断路</el-checkbox
                      >
                      <el-checkbox label="U_N_DISCONNECT"
                        >N相电压断路</el-checkbox
                      >
                    </el-checkbox-group>
                  </div>
                  <div v-if="props.currentData.wiringType != '单相'">
                    <fieldset>
                      <legend>电压相序:</legend>
                      <div>
                        <el-radio-group class="item" v-model="twfForm.vps">
                          <el-radio label="U_ABC">ABC</el-radio>
                          <el-radio label="U_ACB">ACB</el-radio>
                          <el-radio label="U_BAC">BAC</el-radio>
                          <el-radio label="U_BCA">BCA</el-radio>
                        </el-radio-group>
                      </div>
                    </fieldset>
                  </div>
                </div>
              </fieldset>
              <fieldset>
                <legend>电流线路故障:</legend>
                <div class="ll-bw-item2">
                  <div class="item">
                    <el-checkbox-group class="item" v-model="twfForm.clf">
                      <el-checkbox label="IA_CROSS">A相电流反极</el-checkbox>
                      <el-checkbox label="IB_CROSS">B相电流反极</el-checkbox>
                      <el-checkbox label="IC_CROSS">C相电流反极</el-checkbox>
                    </el-checkbox-group>
                  </div>
                  <div class="item">
                    <el-checkbox-group class="item" v-model="twfForm.clf">
                      <el-checkbox label="IA_PASS">IA短路</el-checkbox>
                      <el-checkbox label="IB_PASS">IB短路</el-checkbox>
                      <el-checkbox label="IC_PASS">IC短路</el-checkbox>
                    </el-checkbox-group>
                  </div>
                  <div
                    class="item"
                    v-if="props.currentData.wiringType != '单相'"
                  >
                    <el-checkbox-group class="item" v-model="twfForm.clf">
                      <el-checkbox label="IA_OPEN">A相电流开路</el-checkbox>
                      <el-checkbox label="IB_OPEN">B相电流开路</el-checkbox>
                      <el-checkbox label="IC_OPEN">C相电流开路</el-checkbox>
                    </el-checkbox-group>
                  </div>
                  <div v-if="props.currentData.wiringType != '单相'">
                    <fieldset>
                      <legend>电流线路故障:</legend>
                      <el-radio-group class="item" v-model="twfForm.cps">
                        <el-radio label="I_ABC">ABC</el-radio>
                        <el-radio label="I_CBA">CBA</el-radio>
                        <el-radio label="I_ACB">ACB</el-radio>
                        <el-radio label="I_CAB">CAB</el-radio>
                      </el-radio-group>
                    </fieldset>
                  </div>
                </div>
              </fieldset>
            </el-form>
          </div>
        </fieldset>
        <fieldset class="ef-collect-w-1">
          <legend>表计故障:</legend>
          <div v-if="props.currentData.wiringType != '单相'">
            <el-form class="ll-bj" ref="meterMalRef" :model="meterMalForm">
              <div class="ll-item1">
                <div>
                  <el-checkbox-group v-model="meterMalForm.fault1" class="item">
                    <el-checkbox label="1">485通信故障</el-checkbox>
                    <el-checkbox label="6">断相A相</el-checkbox>
                    <el-checkbox label="7">断相B相</el-checkbox>
                    <el-checkbox label="8">断相C相</el-checkbox>
                  </el-checkbox-group>
                </div>
                <div>
                  <el-checkbox-group v-model="meterMalForm.fault2" class="item">
                    <el-checkbox label="2">红外通信故障</el-checkbox>
                    <el-checkbox label="9">时间显示故障</el-checkbox>
                    <el-checkbox label="10">数据显示故障</el-checkbox>
                    <el-checkbox label="11">数据读取故障</el-checkbox>
                  </el-checkbox-group>
                </div>
                <div>
                  <el-checkbox-group v-model="meterMalForm.fault3" class="item">
                    <el-checkbox label="3">脉冲灯故障</el-checkbox>
                    <el-checkbox label="12">逆向序</el-checkbox>
                    <el-checkbox label="13">时钟故障</el-checkbox>
                    <el-checkbox label="14">死机故障</el-checkbox>
                  </el-checkbox-group>
                </div>
                <div>
                  <el-checkbox-group v-model="meterMalForm.fault4" class="item">
                    <el-checkbox label="4">分合闸故障</el-checkbox>
                    <el-checkbox label="15">电能突变故障</el-checkbox>
                    <el-checkbox label="16">时钟电池欠压</el-checkbox>
                    <el-checkbox label="5">电能表不启动</el-checkbox>
                    <!-- <el-checkbox label="17">主供电电池欠压</el-checkbox> -->
                  </el-checkbox-group>
                </div>
                <div>
                  <el-checkbox-group v-model="meterMalForm.fault5" class="item">
                    <el-checkbox label="18">电能表花屏</el-checkbox>
                    <el-checkbox label="19">电能表黑屏</el-checkbox>
                    <el-checkbox label="20">电能表白屏</el-checkbox>
                  </el-checkbox-group>
                </div>
              </div>
              <div class="ll-item2">
                <div class="ll-item2-1">
                  <div>
                    <el-checkbox-group
                      v-model="meterMalForm.fault6"
                      class="item"
                    >
                      <el-checkbox label="21">失压A相</el-checkbox>
                      <el-checkbox label="22">失压B相</el-checkbox>
                      <el-checkbox label="23">失压C相</el-checkbox>
                    </el-checkbox-group>
                  </div>
                  <div>
                    <!-- <el-checkbox-group
                      v-model="meterMalForm.fault7"
                      class="item"
                    >
                      <el-checkbox label="27">电能表A相无电压</el-checkbox>
                      <el-checkbox label="28">电能表B相无电压</el-checkbox>
                      <el-checkbox label="29">电能表C相无电压</el-checkbox>
                    </el-checkbox-group> -->
                  </div>
                  <div>
                    <el-checkbox-group
                      v-model="meterMalForm.fault8"
                      class="item"
                    >
                      <el-checkbox label="33">电能表A相电压异常</el-checkbox>
                      <el-checkbox label="34">电能表B相电压异常</el-checkbox>
                      <el-checkbox label="35">电能表C相电压异常</el-checkbox>
                    </el-checkbox-group>
                  </div>
                </div>
                <div class="ll-item2-1">
                  <div>
                    <el-checkbox-group
                      v-model="meterMalForm.fault9"
                      class="item"
                    >
                      <el-checkbox label="24">失流A相</el-checkbox>
                      <el-checkbox label="25">失流B相</el-checkbox>
                      <el-checkbox label="26">失流C相</el-checkbox>
                    </el-checkbox-group>
                  </div>
                  <div>
                    <!-- <el-checkbox-group
                      v-model="meterMalForm.fault10"
                      class="item"
                    >
                      <el-checkbox label="30">电能表A相无电流</el-checkbox>
                      <el-checkbox label="31">电能表B相无电流</el-checkbox>
                      <el-checkbox label="32">电能表C相无电流</el-checkbox>
                    </el-checkbox-group> -->
                  </div>
                  <div>
                    <el-checkbox-group
                      v-model="meterMalForm.fault11"
                      class="item"
                    >
                      <el-checkbox label="36">电能表A相电流异常</el-checkbox>
                      <el-checkbox label="37">电能表B相电流异常</el-checkbox>
                      <el-checkbox label="38">电能表C相电流异常</el-checkbox>
                    </el-checkbox-group>
                  </div>
                </div>
              </div>
            </el-form>
          </div>
          <div v-else>
            <el-form class="ll-bj" ref="meterMalRef" :model="meterMalForm">
              <div class="ll-item1">
                <div>
                  <el-checkbox-group v-model="meterMalForm.fault1" class="item">
                    <el-checkbox label="1">数据读取故障</el-checkbox>
                    <el-checkbox label="2">死机故障</el-checkbox>
                    <el-checkbox label="4">断相</el-checkbox>
                    <el-checkbox label="6">液晶显示</el-checkbox>
                    <el-checkbox label="5">电能表黑屏</el-checkbox>
                    <el-checkbox label="11">时间异常</el-checkbox>
                  </el-checkbox-group>
                </div>
                <div>
                  <el-checkbox-group v-model="meterMalForm.fault2" class="item">
                    <el-checkbox label="3">拉闸故障</el-checkbox>
                    <el-checkbox label="7">红外通信故障</el-checkbox>
                    <el-checkbox label="8">485回传故障</el-checkbox>
                    <el-checkbox label="9">失流故障</el-checkbox>
                    <el-checkbox label="10">失压故障</el-checkbox>
                  </el-checkbox-group>
                </div>
              </div>
            </el-form>
          </div>
        </fieldset>
      </div>
      <div class="ll-btn2">
        <el-button @click="clearSubmit()">恢复故障</el-button>
        <el-button @click="handleSubmit()">设置故障</el-button>
      </div>
    </el-tab-pane>
  </el-tabs>
</template>

<script setup>
import { ref, reactive, watch, onMounted, nextTick } from "vue";
import { ElMessage } from "element-plus";
import { lineLossData } from "@/gm/meterLabel.js";
import { useAppStore } from "@/stores";
import { storeToRefs } from "pinia";

const useApp = useAppStore();
let {
  currentPlanId,
  tableFaultSetting,
  tableVoltage,
  meterCurrent,
  isSuccess,
  faultLoading,
} = storeToRefs(useApp);
import {
  meterRelayFault,
  meterJzqFault,
  meterRelayFaultRecoveryAll,
  meterJzqFaultRecoveryAll,
  meterFzbFault,
  meterFzbSingleFault,
  meterFzbFaultRecoveryAll,
  meterFzbSingleFaultRecoveryAll,
} from "@/api/source.js";

const props = defineProps({
  position: String,
  currentData: Object,
});
const tabPosition = ref("left");
// console.log(lineLossData);
const tableData = lineLossData;
const radio = ref(1);
const loading = ref(false);
const checkList = ref([]);
const twfFormRef = ref();
const meterMalRef = ref();
const twfForm = reactive({
  ttype: [],
  vlf: [],
  vps: "U_ABC",
  clf: [],
  cps: "I_ABC",
});
const meterMalForm = reactive({
  fault1: [],
  fault2: [],
  fault3: [],
  fault4: [],
  fault5: [],
  fault6: [],
  fault7: [],
  fault8: [],
  fault9: [],
  fault10: [],
  fault11: [],
});
let successNum = ref(0);
let errorNum = ref(0);

onMounted(() => {
  init(props.position);
  watch(
    twfForm,
    (newValue, oldValue) => {
      tableFaultSetting.value[props.position + "a"] = newValue;
    },
    { immediate: true },
    { deep: true }
  );
  watch(
    meterMalForm,
    (newValue, oldValue) => {
      tableFaultSetting.value[props.position + "b2"] = newValue;
    },
    { immediate: true },
    { deep: true }
  );
});
//初始化数据
const init = (parm) => {
  // console.log("aaa", parm, tableFaultSetting.value, props.position);
  if (parm != undefined && parm != "undefined" && parm) {
    if (tableFaultSetting.value[parm + "a"]) {
      twfForm.ttype = tableFaultSetting.value[parm + "a"].ttype;
      twfForm.vlf = tableFaultSetting.value[parm + "a"].vlf;
      twfForm.vps = tableFaultSetting.value[parm + "a"].vps;
      twfForm.clf = tableFaultSetting.value[parm + "a"].clf;
      twfForm.cps = tableFaultSetting.value[parm + "a"].cps;
    }
    if (tableFaultSetting.value[parm + "b2"]) {
      meterMalForm.fault1 = tableFaultSetting.value[parm + "b2"].fault1;
      meterMalForm.fault2 = tableFaultSetting.value[parm + "b2"].fault2;
      meterMalForm.fault3 = tableFaultSetting.value[parm + "b2"].fault3;
      meterMalForm.fault4 = tableFaultSetting.value[parm + "b2"].fault4;
      meterMalForm.fault5 = tableFaultSetting.value[parm + "b2"].fault5;
      meterMalForm.fault6 = tableFaultSetting.value[parm + "b2"].fault6;
      meterMalForm.fault7 = tableFaultSetting.value[parm + "b2"].fault7;
      meterMalForm.fault8 = tableFaultSetting.value[parm + "b2"].fault8;
      meterMalForm.fault9 = tableFaultSetting.value[parm + "b2"].fault9;
      meterMalForm.fault10 = tableFaultSetting.value[parm + "b2"].fault10;
      meterMalForm.fault11 = tableFaultSetting.value[parm + "b2"].fault11;
    }
  }
};
// 设置故障
const handleSubmit = async (obj = "") => {
  let pos = Number(props.position);
  if (obj != "undefined" && obj && obj != undefined) {
    pos = Number(obj.position);
    isSuccess.value = true;
    if (tableFaultSetting.value[pos + "a"]) {
      twfForm.ttype = tableFaultSetting.value[pos + "a"].ttype;
      twfForm.vlf = tableFaultSetting.value[pos + "a"].vlf;
      twfForm.vps = tableFaultSetting.value[pos + "a"].vps;
      twfForm.clf = tableFaultSetting.value[pos + "a"].clf;
      twfForm.cps = tableFaultSetting.value[pos + "a"].cps;
    }
    if (tableFaultSetting.value[pos + "b2"]) {
      meterMalForm.fault1 = tableFaultSetting.value[pos + "b2"].fault1;
      meterMalForm.fault2 = tableFaultSetting.value[pos + "b2"].fault2;
      meterMalForm.fault3 = tableFaultSetting.value[pos + "b2"].fault3;
      meterMalForm.fault4 = tableFaultSetting.value[pos + "b2"].fault4;
      meterMalForm.fault5 = tableFaultSetting.value[pos + "b2"].fault5;
      meterMalForm.fault6 = tableFaultSetting.value[pos + "b2"].fault6;
      meterMalForm.fault7 = tableFaultSetting.value[pos + "b2"].fault7;
      meterMalForm.fault8 = tableFaultSetting.value[pos + "b2"].fault8;
      meterMalForm.fault9 = tableFaultSetting.value[pos + "b2"].fault9;
      meterMalForm.fault10 = tableFaultSetting.value[pos + "b2"].fault10;
      meterMalForm.fault11 = tableFaultSetting.value[pos + "b2"].fault11;
    }
  }
  faultLoading.value = true;
  let faultCodes1 = "";
  let faultCodes2 = "";
  let result = Object.values(twfForm);
  let meterMalResult = Object.values(meterMalForm);
  for (let i = 0; i < result.length; i++) {
    let str = result[i];
    if (Array.isArray(result[i])) {
      str = result[i].join(",");
    }
    if (faultCodes1) faultCodes1 += "," + str;
    else faultCodes1 = str;
  }

  for (let i = 0; i < meterMalResult.length; i++) {
    // console.log(meterMalResult[i]);
    let str = meterMalResult[i];
    if (Array.isArray(meterMalResult[i])) {
      str = meterMalResult[i].join(",");
    }
    // let str = meterMalResult[i].join(",");
    if (str) {
      if (faultCodes2) faultCodes2 += "," + str;
      else faultCodes2 = str;
    }
  }

  let parm = { planId: currentPlanId.value, pos, faultCodes1 };
  let parm1 = { planId: currentPlanId.value, pos, faultCodes2 };
  //故障设置-分步发送
  meterRelayFaultApi(parm, parm1, faultCodes2, obj); //设置表位故障
  // nextTick(() => {
  //   loading.value = false;
  // });
};
const secondStep = (parm1, faultCodes2, obj) => {
  let arr = [3, 4, 7, 8];
  //1台区；2台区下终端；3台区下总表；4台区下用户表；5转变用户；6专变下终端；7专变下用户表；8用户表
  let type = props.currentData.type;
  let pos = props.position;
  let wiringType = props.currentData.wiringType;
  if (obj != "undefined" && obj && obj != undefined) {
    type = Number(obj.type);
    pos = Number(obj.position);
    wiringType = obj.wiringType;
  }
  if (type === 2 || type === 6) {
    meterJzqFaultApi(parm1, obj); //设置表计故障
  }
  if (arr.includes(type)) {
    let parm2 = {
      planId: currentPlanId.value,
      pos,
      faultCodes: faultCodes2,
    };
    if (wiringType === "单相") {
      meterFzbSingleFaultApi(parm2, obj); //设置单相表
    } else {
      meterFzbFaultApi(parm2, obj); //设置三相表
    }
  }
};
// 清除故障
const clearSubmit = async (obj) => {
  let pos = Number(props.position);
  if (obj != "undefined" && obj && obj != undefined) {
    pos = Number(obj.position);
    isSuccess.value = true;
  }
  faultLoading.value = true;
  let parm = {
    pos,
    planId: currentPlanId.value,
  };
  //故障恢复-分步发送
  meterRelayFaultRecoveryAllApi(parm, obj); //设置表位故障
};
//表位接线故障恢复所有
const meterRelayFaultRecoveryAllApi = async (parm, obj) => {
  let pos = Number(props.position);
  if (obj != "undefined" && obj && obj != undefined) {
    pos = Number(obj.position);
  }
  await meterRelayFaultRecoveryAll(parm)
    .then((res) => {
      // console.log(res);
      secondStepClear(parm, obj);
      twfForm.ttype = [];
      twfForm.vlf = [];
      twfForm.vps = "U_ABC";
      twfForm.clf = [];
      twfForm.cps = "I_ABC";
      meterMalForm.fault1 = [];
      meterMalForm.fault2 = [];
      meterMalForm.fault3 = [];
      meterMalForm.fault4 = [];
      meterMalForm.fault5 = [];
      meterMalForm.fault6 = [];
      meterMalForm.fault7 = [];
      meterMalForm.fault8 = [];
      meterMalForm.fault9 = [];
      meterMalForm.fault10 = [];
      meterMalForm.fault11 = [];
      tableFaultSetting.value[pos + "b2"] = meterMalForm;
      tableFaultSetting.value[pos + "a"] = twfForm;
    })
    .catch((err) => {
      console.log(err);
      secondStepClear(parm, obj);
    });
};
//集中器故障恢复所有
const meterJzqFaultRecoveryAllApi = async (parm) => {
  await meterJzqFaultRecoveryAll(parm)
    .then((res) => {
      // console.log(res);
      twfForm.ttype = [];
      twfForm.vlf = [];
      twfForm.vps = "U_ABC";
      twfForm.clf = [];
      twfForm.cps = "I_ABC";
      meterMalForm.fault1 = [];
      meterMalForm.fault2 = [];
      meterMalForm.fault3 = [];
      meterMalForm.fault4 = [];
      meterMalForm.fault5 = [];
      meterMalForm.fault6 = [];
      meterMalForm.fault7 = [];
      meterMalForm.fault8 = [];
      meterMalForm.fault9 = [];
      meterMalForm.fault10 = [];
      faultLoading.value = false;
      isSuccess.value = false;
    })
    .catch((err) => {
      console.log(err);
      faultLoading.value = false;
      isSuccess.value = false;
    });
};
//三相表故障恢复所有
const meterFzbFaultRecoveryAllApi = async (parm, obj) => {
  let pos = props.position;
  if (obj != "undefined" && obj && obj != undefined) {
    pos = Number(obj.position);
  }
  await meterFzbFaultRecoveryAll(parm)
    .then((res) => {
      // console.log(res);
      twfForm.ttype = [];
      twfForm.vlf = [];
      twfForm.vps = "U_ABC";
      twfForm.clf = [];
      twfForm.cps = "I_ABC";
      meterMalForm.fault1 = [];
      meterMalForm.fault2 = [];
      meterMalForm.fault3 = [];
      meterMalForm.fault4 = [];
      meterMalForm.fault5 = [];
      meterMalForm.fault6 = [];
      meterMalForm.fault7 = [];
      meterMalForm.fault8 = [];
      meterMalForm.fault9 = [];
      meterMalForm.fault10 = [];
      tableFaultSetting.value[pos + "b2"] = meterMalForm;
      tableFaultSetting.value[pos + "a"] = twfForm;
      faultLoading.value = false;
      isSuccess.value = false;
    })
    .catch((err) => {
      console.log(err);
      faultLoading.value = false;
      isSuccess.value = false;
    });
};
//单相表故障恢复所有
const meterFzbSingleFaultRecoveryAllApi = async (parm, obj) => {
  let pos = props.position;
  if (obj != "undefined" && obj && obj != undefined) {
    pos = Number(obj.position);
  }
  await meterFzbSingleFaultRecoveryAll(parm)
    .then((res) => {
      // console.log(res);
      twfForm.ttype = [];
      twfForm.vlf = [];
      twfForm.vps = "U_ABC";
      twfForm.clf = [];
      twfForm.cps = "I_ABC";
      meterMalForm.fault1 = [];
      meterMalForm.fault2 = [];
      meterMalForm.fault3 = [];
      meterMalForm.fault4 = [];
      meterMalForm.fault5 = [];
      meterMalForm.fault6 = [];
      meterMalForm.fault7 = [];
      meterMalForm.fault8 = [];
      meterMalForm.fault9 = [];
      meterMalForm.fault10 = [];
      tableFaultSetting.value[pos + "b2"] = meterMalForm;
      tableFaultSetting.value[pos + "a"] = twfForm;
      faultLoading.value = false;
      isSuccess.value = false;
    })
    .catch((err) => {
      console.log(err);
      faultLoading.value = false;
      isSuccess.value = false;
    });
};
const secondStepClear = (parm, obj) => {
  let arr = [3, 4, 7, 8];
  //1台区；2台区下终端；3台区下总表；4台区下用户表；5转变用户；6专变下终端；7专变下用户表；8用户表
  let type = props.currentData.type;
  let pos = props.position;
  let wiringType = props.currentData.wiringType;
  if (obj != "undefined" && obj && obj != undefined) {
    type = Number(obj.type);
    pos = Number(obj.position);
    wiringType = obj.wiringType;
  }
  if (type === 2 || type === 6) {
    meterJzqFaultRecoveryAllApi(parm, obj); //设置表计故障
  }
  if (arr.includes(type)) {
    if (wiringType === "单相") {
      meterFzbSingleFaultRecoveryAllApi(parm, obj); //设置单相表
    } else {
      meterFzbFaultRecoveryAllApi(parm, obj); //设置三相表
    }
  }
};
//设置表位故障
const meterRelayFaultApi = async (parm, parm1, faultCodes2, obj) => {
  await meterRelayFault(parm)
    .then((res) => {
      // console.log(res);
      secondStep(parm1, faultCodes2, obj);
      successNum.value++;
      getMessage();
      tableFaultSetting.value[props.position + "a"] = twfForm;
    })
    .catch((err) => {
      secondStep(parm1, faultCodes2, obj);
      errorNum.value++;
      getMessage();
    });
};
//设置表计故障
const meterJzqFaultApi = async (parm, obj) => {
  let pos = props.position;
  if (obj != "undefined" && obj && obj != undefined) {
    pos = Number(obj.position);
  }
  await meterJzqFault(parm)
    .then((res) => {
      // console.log(res);
      successNum.value++;
      tableFaultSetting.value[pos + "b2"] = twfForm;
      getMessage();
    })
    .catch((err) => {
      errorNum.value++;
      getMessage();
    });
};
//设置三相表
const meterFzbFaultApi = async (parm, obj) => {
  let pos = props.position;
  if (obj != "undefined" && obj && obj != undefined) {
    pos = Number(obj.position);
  }
  await meterFzbFault(parm)
    .then((res) => {
      // console.log(res);
      successNum.value++;
      tableFaultSetting.value[pos + "b2"] = meterMalForm;
      getMessage();
    })
    .catch((err) => {
      console.log(err);
      errorNum.value++;
      getMessage();
    });
};
//设置单相表
const meterFzbSingleFaultApi = async (parm, obj) => {
  let pos = props.position;
  if (obj != "undefined" && obj && obj != undefined) {
    pos = Number(obj.position);
  }
  await meterFzbSingleFault(parm)
    .then((res) => {
      // console.log(res);
      successNum.value++;
      tableFaultSetting.value[pos + "b2"] = meterMalForm;
      getMessage();
    })
    .catch((err) => {
      console.log(err);
      errorNum.value++;
      getMessage();
    });
};
const getMessage = () => {
  let num = successNum.value + Number(errorNum.value);
  if (num === 2) {
    faultLoading.value = false;
    successNum.value = 0;
    errorNum.value = 0;
    isSuccess.value = false;
  }
};
defineExpose({
  init,
  handleSubmit,
  clearSubmit,
});
</script>

<style lang="scss" scoped>
//功率源
.line-Loss {
  .ll-tab {
    display: flex;
  }
  .ll-content {
    display: flex;
    .ll-bw {
      display: flex;
      justify-content: center;
      .ll-bw-item1 {
        display: flex;
        flex-direction: column;
        padding: 2px 10px;
      }
      .ll-bw-item2 {
        display: flex;
      }
    }
    .ll-bj {
      padding: 5px;
      .ll-item1 {
        display: flex;
        justify-content: center;
      }
      .ll-item2 {
        display: flex;
        justify-content: center;
        .ll-item2-1 {
          display: flex;
          border: 1px solid #ebeef5;
        }
      }
    }
    .el-checkbox {
      height: 24px;
    }
    .el-radio {
      height: 23px;
    }
    .item-border {
      border: 1px solid #ebeef5;
      margin: 2px 10px;
    }
    .item {
      display: flex;
      flex-direction: column;
      padding: 2px 2px;
    }
  }
  .ll-btn1 {
    flex-grow: 1;
  }
  .ll-btn2 {
    width: 100px;
    display: flex;
    flex-direction: column;
    align-items: end;
    justify-content: end;
    margin-bottom: 100px !important;
    .el-button {
      width: 90px;
      margin-top: 10px;
    }
  }
}
</style>
<style lang="scss">
.line-Loss {
  .ll-btn2-1 {
    width: 100px;
    display: flex;
    flex-direction: column;
    align-items: end;
    justify-content: end;
    margin-bottom: 100px !important;
    .el-button {
      width: 90px;
      margin-top: 10px;
    }
  }
}
</style>
